import 'dart:convert';

class TempHumidity {
  double indoorTemperature;
  double indoorHumidity;
  bool heatStatus;
  bool dehumidifyStatus;
  bool exhaustStatus;
  bool airConStatus;
  bool autoStatus;
  bool alarmStatus;
  bool airCleanStatus;
  TempHumidity({
    required this.indoorTemperature,
    required this.indoorHumidity,
    required this.heatStatus,
    required this.dehumidifyStatus,
    required this.exhaustStatus,
    required this.airConStatus,
    required this.autoStatus,
    required this.alarmStatus,
    required this.airCleanStatus,
  });

  TempHumidity copyWith({
    double? indoorTemperature,
    double? indoorHumidity,
    bool? heatStatus,
    bool? dehumidifyStatus,
    bool? exhaustStatus,
    bool? airConStatus,
    bool? autoStatus,
    bool? alarmStatus,
    bool? airCleanStatus,
  }) {
    return TempHumidity(
      indoorTemperature: indoorTemperature ?? this.indoorTemperature,
      indoorHumidity: indoorHumidity ?? this.indoorHumidity,
      heatStatus: heatStatus ?? this.heatStatus,
      dehumidifyStatus: dehumidifyStatus ?? this.dehumidifyStatus,
      exhaustStatus: exhaustStatus ?? this.exhaustStatus,
      airConStatus: airConStatus ?? this.airConStatus,
      autoStatus: autoStatus ?? this.autoStatus,
      alarmStatus: alarmStatus ?? this.alarmStatus,
      airCleanStatus: airCleanStatus ?? this.airCleanStatus,
    );
  }

  Map<String, dynamic> toMap() {
    return <String, dynamic>{
      'indoorTemperature': indoorTemperature,
      'indoorHumidity': indoorHumidity,
      'heatStatus': heatStatus,
      'dehumidifyStatus': dehumidifyStatus,
      'exhaustStatus': exhaustStatus,
      'airConStatus': airConStatus,
      'autoStatus': autoStatus,
      'alarmStatus': alarmStatus,
      'airCleanStatus': airCleanStatus,
    };
  }

  factory TempHumidity.fromMap(Map<String, dynamic> map) {
    return TempHumidity(
      indoorTemperature: map['indoorTemperature'] as double,
      indoorHumidity: map['indoorHumidity'] as double,
      heatStatus: map['heatStatus'] as bool,
      dehumidifyStatus: map['dehumidifyStatus'] as bool,
      exhaustStatus: map['exhaustStatus'] as bool,
      airConStatus: map['airConStatus'] as bool,
      autoStatus: map['autoStatus'] as bool,
      alarmStatus: map['alarmStatus'] as bool,
      airCleanStatus: map['airCleanStatus'] as bool,
    );
  }

  String toJson() => json.encode(toMap());

  factory TempHumidity.fromJson(String source) => TempHumidity.fromMap(json.decode(source) as Map<String, dynamic>);

  @override
  String toString() {
    return 'TempHumidity(indoorTemperature: $indoorTemperature, indoorHumidity: $indoorHumidity, heatStatus: $heatStatus, dehumidifyStatus: $dehumidifyStatus, exhaustStatus: $exhaustStatus, airConStatus: $airConStatus, autoStatus: $autoStatus, alarmStatus: $alarmStatus, airCleanStatus: $airCleanStatus)';
  }

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;

    return other is TempHumidity &&
        other.indoorTemperature == indoorTemperature &&
        other.indoorHumidity == indoorHumidity &&
        other.heatStatus == heatStatus &&
        other.dehumidifyStatus == dehumidifyStatus &&
        other.exhaustStatus == exhaustStatus &&
        other.airConStatus == airConStatus &&
        other.autoStatus == autoStatus &&
        other.alarmStatus == alarmStatus &&
        other.airCleanStatus == airCleanStatus;
  }

  @override
  int get hashCode {
    return indoorTemperature.hashCode ^
    indoorHumidity.hashCode ^
    heatStatus.hashCode ^
    dehumidifyStatus.hashCode ^
    exhaustStatus.hashCode ^
    airConStatus.hashCode ^
    autoStatus.hashCode ^
    alarmStatus.hashCode ^
    airCleanStatus.hashCode;
  }
}